package cn.longge.mapper;

import cn.longge.entity.WorkOrder;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface WorkOrderMapper extends Mapper<WorkOrder> {

    @SelectProvider(value = WorkSqlProvider.class,method = "selectByCondition")
    List<WorkOrder> selectByCondition(Map<String,Object> params);

    @Select("select wo.id,wo.code,wo.`status`,cu.name as create_user_name,co.name as create_office_name,tu.name " +
            "as transport_user_name,tof.name as transport_office_name, ru.name as resipient_user_name," +
            "ro.name as resipient_office_name,cu.phone as create_user_phone,tu.phone as transport_user_phone,ru.phone as resipient_user_phone\n" +
            "from work_order wo \n" +
            "left join sys_user cu \n" +
            "on wo.create_user_id = cu.id \n" +
            "left join sys_user tu \n" +
            "on wo.transport_user_id = tu.id \n" +
            "left join sys_user ru \n" +
            "on wo.recipient_user_id = ru.id \n" +
            "left join sys_office co\n" +
            "on cu.office_id = co.id \n" +
            "left join sys_office tof\n" +
            "on tu.office_id = tof.id \n" +
            "left join sys_office ro\n" +
            "on ru.office_id = ro.id \n" +
            "where wo.del_flag = 0 and wo.id = #{id}")
    WorkOrder selectDetail(int id);
}